/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.sistemas.be;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author WILLIAM
 */
@Entity
@Table(name = "sis_requerimiento")
//@NamedQueries({
//    @NamedQuery(name = "SisRequerimiento.findAll", query = "SELECT s FROM SisRequerimiento s"),
//    @NamedQuery(name = "SisRequerimiento.findByReqCodigo", query = "SELECT s FROM SisRequerimiento s WHERE s.reqCodigo = :reqCodigo"),
//    @NamedQuery(name = "SisRequerimiento.findByReqArea", query = "SELECT s FROM SisRequerimiento s WHERE s.reqArea = :reqArea"),
//    @NamedQuery(name = "SisRequerimiento.findByReqSolicitante", query = "SELECT s FROM SisRequerimiento s WHERE s.reqSolicitante = :reqSolicitante"),
//    @NamedQuery(name = "SisRequerimiento.findByReqUso", query = "SELECT s FROM SisRequerimiento s WHERE s.reqUso = :reqUso"),
//    @NamedQuery(name = "SisRequerimiento.findByReqFecha", query = "SELECT s FROM SisRequerimiento s WHERE s.reqFecha = :reqFecha"),
//    @NamedQuery(name = "SisRequerimiento.findByReqObservacion", query = "SELECT s FROM SisRequerimiento s WHERE s.reqObservacion = :reqObservacion"),
//    @NamedQuery(name = "SisRequerimiento.findByReqTiporequerimiento", query = "SELECT s FROM SisRequerimiento s WHERE s.reqTiporequerimiento = :reqTiporequerimiento")})
public class SisRequerimiento implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "req_codigo")
    private Integer reqCodigo;
    @Basic(optional = false)
    @Column(name = "req_area")
    private String reqArea;
    @Basic(optional = false)
    @Column(name = "req_solicitante")
    private String reqSolicitante;
    @Basic(optional = false)
    @Column(name = "req_uso")
    private String reqUso;
    @Basic(optional = false)
    @Column(name = "req_fecha")
    @Temporal(TemporalType.DATE)
    private Date reqFecha;
    @Column(name = "req_estado")
    private Integer reqEstado;
    @Column(name = "req_horaingreso")
    private String reqHoraIngreso;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "reqCodigo", fetch = FetchType.LAZY)
    private List<SisDetalleRequerimiento> sisDetalleRequerimientoList;

    public SisRequerimiento() {
    }

    public SisRequerimiento(Integer reqCodigo) {
        this.reqCodigo = reqCodigo;
    }

    public SisRequerimiento(Integer reqCodigo, String reqArea, String reqSolicitante, String reqUso, Date reqFecha) {
        this.reqCodigo = reqCodigo;
        this.reqArea = reqArea;
        this.reqSolicitante = reqSolicitante;
        this.reqUso = reqUso;
        this.reqFecha = reqFecha;
    }

    public Integer getReqCodigo() {
        return reqCodigo;
    }

    public void setReqCodigo(Integer reqCodigo) {
        this.reqCodigo = reqCodigo;
    }

    public String getReqArea() {
        return reqArea;
    }

    public void setReqArea(String reqArea) {
        this.reqArea = reqArea;
    }

    public String getReqSolicitante() {
        return reqSolicitante;
    }

    public void setReqSolicitante(String reqSolicitante) {
        this.reqSolicitante = reqSolicitante;
    }

    public String getReqUso() {
        return reqUso;
    }

    public void setReqUso(String reqUso) {
        this.reqUso = reqUso;
    }

    public Date getReqFecha() {
        return reqFecha;
    }

    public void setReqFecha(Date reqFecha) {
        this.reqFecha = reqFecha;
    }

    public List<SisDetalleRequerimiento> getSisDetalleRequerimientoList() {
        return sisDetalleRequerimientoList;
    }

    public void setSisDetalleRequerimientoList(List<SisDetalleRequerimiento> sisDetalleRequerimientoList) {
        this.sisDetalleRequerimientoList = sisDetalleRequerimientoList;
    }

    public Integer getReqEstado() {
        return reqEstado;
    }

    public void setReqEstado(Integer reqEstado) {
        this.reqEstado = reqEstado;
    }

    public String getReqHoraIngreso() {
        return reqHoraIngreso;
    }

    public void setReqHoraIngreso(String reqHoraIngreso) {
        this.reqHoraIngreso = reqHoraIngreso;
    }

    public String getEstadoActual(){

        String retorno = "";

        switch(reqEstado){

            case 0 : retorno = "Rececpionado"; break;
            case 1 : retorno = "Por Atender"; break;
            case 2 : retorno = "Atendido"; break;
            case 3 : retorno = "Rechazado"; break;

        }
        return retorno;
    }
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (reqCodigo != null ? reqCodigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SisRequerimiento)) {
            return false;
        }
        SisRequerimiento other = (SisRequerimiento) object;
        if ((this.reqCodigo == null && other.reqCodigo != null) || (this.reqCodigo != null && !this.reqCodigo.equals(other.reqCodigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.cip.esymons.sistemas.be.SisRequerimiento[reqCodigo=" + reqCodigo + "]";
    }

}
